package model;

import java.util.LinkedList;

/**
 *
 * @author julien
 */
public class Model {
    
    private LinkedList<RemoteUser> user_list;
    private LocalUser local_user;
    
    public Model(LocalUser l_user){
       user_list = new <RemoteUser>LinkedList();
       local_user = l_user;
    }
    
    public LocalUser getLocalUser(){
        return local_user;
    }
    
    public void setNameLocalUser(String name){
        local_user.setNom(name);
    }
    
    public LinkedList getRemoteUsers()
    {
        return user_list;
    }
    
    public void addRemoteUser(RemoteUser r_user)
    {
        if (!user_list.contains(r_user)){
            user_list.add(r_user);
        }
        System.out.println(user_list.toString());
    }
    
    public void delRemoteUser(RemoteUser r_user)
    {
        user_list.remove(r_user);
        System.out.println(user_list.toString());
    }
    
    public RemoteUser checkRemoteUser (String hostaddr)
    {
        RemoteUser r = null;
        for(RemoteUser r_user : user_list)
        {
            if (r_user.getAddr().equals(hostaddr))
                r = r_user;
        }
        return r;
    }
}
